#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main() {
	int t = 0;
	scanf("%d", &t);
	int h, m, s = 0;
	if (t < 43200) {
		int h = t / 3600;
		int m = (t - h * 3600) / 60;
		int s = t % 60;
		printf("%02d:%02d:%02d am", h, m, s);
	}
	if (t > 43200 && t < 46800) {
		int h = t/ 3600;
		int m = (t -h*3600) / 60;
		int s = t % 60;
		printf("%02d:%02d:%02d midnoon", h, m, s);
	}
	if (t > 46800) {
		int h = (t - 43200) / 3600;
		int m = (t - 43200 - h*3600) / 60;
		int s = (t - 43200) % 60;
		printf("%02d:%02d:%02d pm", h, m, s);
	}
	return 0;
}